﻿CREATE TABLE [dbo].[Station] (
    [Station_ID]        INT            IDENTITY (1, 1) NOT NULL,
    [Code]              NVARCHAR (7)   NOT NULL,
    [FullCode]          NVARCHAR (7)   NULL,
    [Name]              NVARCHAR (100) NULL,
    [Mnemocode]         NVARCHAR (10)  NULL,
    [MnemocodeEng]      NVARCHAR (15)  NULL,
    [NameEng]           NVARCHAR (110) NULL,
    [CTM_Country_ID]    NCHAR (2)      CONSTRAINT [DF_Station_CTM_Country_ID] DEFAULT ('00' collate Cyrillic_General_CI_AS) NOT NULL,
    [CTM_Country_PP_ID] NCHAR (2)      CONSTRAINT [DF_Station_CTM_Country_PP_ID] DEFAULT ('00' collate Cyrillic_General_CI_AS) NOT NULL,
    [Road_ID]           INT            CONSTRAINT [DF_Station_Road_ID] DEFAULT ((0)) NOT NULL,
    [Region_ID]         INT            CONSTRAINT [DF_Station_Region_ID] DEFAULT ((0)) NOT NULL,
    [IsRepairStation]   BIT            CONSTRAINT [DF_Station_IsRepairStation] DEFAULT ((0)) NOT NULL,
    [IsArriveStation]   BIT            CONSTRAINT [DF_Station_IsArriveStation] DEFAULT ((0)) NOT NULL,
    [IsDispatchStation] BIT            CONSTRAINT [DF_Station_IsDispatchStation] DEFAULT ((0)) NOT NULL,
    [IsUsed]            BIT            CONSTRAINT [DF_Station_IsUsed] DEFAULT ((0)) NOT NULL,
    [IsLocationStation] BIT            CONSTRAINT [DF_Station_IsLocationStation] DEFAULT ((0)) NOT NULL,
    [IsShipmentStation] BIT            CONSTRAINT [DF_Station_IsShipmentStation] DEFAULT ((0)) NOT NULL,
    [Country_PP_ID]     NCHAR (2)      CONSTRAINT [DF_Station_Country_PP_ID] DEFAULT ('00' collate Cyrillic_General_CI_AS) NOT NULL,
    [MirrorStation_ID]  INT            NULL,
    CONSTRAINT [PK_Station] PRIMARY KEY CLUSTERED ([Station_ID] ASC),
    CONSTRAINT [FK_Station_CTM_Country] FOREIGN KEY ([CTM_Country_ID]) REFERENCES [dbo].[CTM_Country] ([CTM_Country_ID]),
    CONSTRAINT [FK_Station_CTM_CountryPP] FOREIGN KEY ([CTM_Country_PP_ID]) REFERENCES [dbo].[CTM_Country] ([CTM_Country_ID]),
    CONSTRAINT [FK_Station_Region] FOREIGN KEY ([Region_ID]) REFERENCES [dbo].[Region] ([Region_ID]),
    CONSTRAINT [FK_Station_Road] FOREIGN KEY ([Road_ID]) REFERENCES [dbo].[Road] ([Road_ID]),
    CONSTRAINT [nvarchar] UNIQUE NONCLUSTERED ([Code] ASC),
    CONSTRAINT [UN_Station_Code] UNIQUE NONCLUSTERED ([Code] ASC),
    CONSTRAINT [UN_Station_FullCode] UNIQUE NONCLUSTERED ([FullCode] ASC)
);

